import { editPassword, queryUserInfo } from '@/services/user';

export default {
    namespace: 'personalCenter',

    state: {
        userInfo: {}
    },

    effects: {
        *editPassword({ payload, callback }, { call }) {
            const response = yield call(editPassword, payload.values);
            callback(response);
        },
        *getUser({ payload }, { call, put }) {
            const response = yield call(queryUserInfo, payload);
            yield put({
                type: 'save',
                payload: {
                    userInfo: response.data
                }
            });
        }
    },

    reducers: {
        save(state, { payload }) {
            return {
                ...state,
                ...payload
            };
        }
    }
};
